<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<link rel="stylesheet" th:href="@{/layui/css/layui.css}">
<script type="text/javascript" th:src="@{/layui/layui.js}"></script>
<script  th:src="@{/js/jquery-3.6.0.min.js}"></script>
<body>
<!--<div onclick="window.location='/pages/back/shopCar/showMyCar'" id="myCarCount" style="cursor: pointer;text-align: center;border: solid lightgray 1px">-->
<!--    我的购物车-->
<!--    <span th:text="${session.carCount}"></span>-->
<!--</div>-->
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-col-md8 layui-col-md-offset2">
            <div style="display:flex">
                <div style="padding-top:35px;">
                    <img th:src="${goods.icon}" style="width: 200px;height: 200px"/>
                </div>
                <div style="padding-top: 20px;">
                    <h2 th:text="${goods.name}" style="font-weight: bold;margin:10px;height: 80px"></h2>
                    <div style="margin: 10px;height: 35px"><span>价格</span><span th:text="${goods.price}" style="font-weight: bold;color: orangered;margin: 10px;font-size: 20px;"></span></div>
                    <div style="margin: 10px;height: 30px;font-weight: bold" th:text="'库存：'+${goods.inventory}" ></div>
                    <div style="display: flex">

                        <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" id="goodsEdit">
                            <i class="layui-icon layui-icon-edit"></i>
                        </button>

                        <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" id="goodsDelete">
                            <i class="layui-icon layui-icon-delete"></i>
                        </button>
                    </div>
                </div>


            </div>
            <div th:utext="${goods.detail}" >

            </div>

        </div>



    </div>

</div>

<script th:inline="javascript" type="text/javascript">


    $(function (){

        layui.use(['table','form','layer'],function(){
            var table=layui.table;
            var layer=layui.layer;
            var form=layui.form;


            $("#goodsEdit").click(function(){
                 let goods = [[${goods}]];
                 console.log(goods);


                window.location = '/seller/goods/goodsEditPre/' + goods.gno





                })


            })

        layui.use('layer',function (){
            $("#goodsDelete").click(function (){
                layer.confirm('确定要删除吗', {
                    btn: ['ok', 'no']},function (){
                    let goods = [[${goods}]];
                    $.ajax({
                        url: '/seller/goods/goodsDelete/'+goods.gno,
                        type: "post",
                        success: function(res){
                            if(res.res){
                                layer.msg(res.msg)
                            }
                        },
                    })
                })


            })
        })
    })
</script>

</body>

</html>